import {
  getQueryString,
} from '@/common/common'
/*扫码签收方法*/
export const scanCodeFn = () => {
  uni.scanCode({
    autoZoom: true,
    onlyFromCamera: true,
    hideAlbum: true,
    success: function(res) {
      const orderNo = getQueryString('orderNo', res.result)
      console.log(orderNo);
      if (!orderNo || !res.result.includes('/distributionPayApplet?orderNo=')) {
        uni.$u.toast('您当前扫码的内容无法识别！')
        return
      }
      uni.navigateTo({
        url: `/subPackages/order/index?orderNo=${orderNo}&pageSource=local`
      })
    }
  });
}
/*跳转电子签收小程序*/
export const navigateToSignOffMiniProgramFn = (orderNo) => {
  const lifeData = uni.getStorageSync('lifeData')
  const appId = 'wxb2167b5d0bf4f53d' //电子签收小程序appId
  const envVersion = uni.getAccountInfoSync().miniProgram.envVersion //打开的对应小程序环境：开发develop、体验trial、生产release
  uni.navigateToMiniProgram({
    appId: appId,
    path: 'subPackages/order/signIn',
    extraData: {
      mobile: lifeData.vuex_accountInfo.mobile,
      orderNo: orderNo,
    },
    envVersion,
    success(res) {
      // 打开成功
    }
  })
}

